package javatwo.annotation.course2.ejb31;

import java.io.IOException;
import java.io.PrintWriter;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(name="singletonServlet",urlPatterns="/singleton")
public class SingletonServlet extends HttpServlet {
	
	@EJB
	private SingletonBean singletonBean = new SingletonBean();
	
	public void doGet(HttpServletRequest request, 
			HttpServletResponse response)
			throws ServletException, IOException {
		
		response.setContentType("text/html;charset=UTF-8");
		PrintWriter pw = response.getWriter();
		singletonBean.addClickCount();
		pw.print("totalCount="+singletonBean.getClickCount());
		pw.close();
		
		
	}

}
